#! /bin/sh
TARGETNAME=pullSDK
TRAGET=libPullSDK.a
MODEL=Release
PROJECT=../UDKLib.xcodeproj
XCODEBUILD=/usr/bin/xcodebuild
SDKROOTDIR=..
INCLUDEPATH=../target/include
PRIFIXDIR=../../../


#过滤是.cpp的文件则删除 参数$1为入参目录


function copyIncludes
{
    SOURCEDIR=$INCLUDEPATH/source
    mkdir $SOURCEDIR

    PDDIR=$INCLUDEPATH/pd
    mkdir $PDDIR
    mkdir $PDDIR/ios

    PULLSDKDIR=$INCLUDEPATH/pullsdk
    mkdir $PULLSDKDIR

    STDSDKDIR=$INCLUDEPATH/stdsdk
    mkdir $STDSDKDIR

    UDKDIR=$INCLUDEPATH/udk
    mkdir $UDKDIR

    cp -rf $PRIFIXDIR/source/include        $SOURCEDIR
    cp -rf $PRIFIXDIR/source/pd/ios/*.h     $PDDIR/ios

    cp -rf $PRIFIXDIR/source/pullsdk/include        $PULLSDKDIR
    cp -rf $PRIFIXDIR/source/stdsdk/include         $STDSDKDIR
    cp -rf $PRIFIXDIR/include                       $UDKDIR
}

mkdir $INCLUDEPATH

$XCODEBUILD -target $TARGETNAME -sdk "iphonesimulator" -configuration $MODEL clean build -project $PROJECT  SYMROOT=./target

$XCODEBUILD -target $TARGETNAME -sdk "iphoneos" -configuration $MODEL clean build -project $PROJECT  SYMROOT=./target

lipo -create $SDKROOTDIR/target/$MODEL-iphonesimulator/$TRAGET $SDKROOTDIR/target/$MODEL-iphoneos/$TRAGET -output  ../target/$TRAGET


if [ -d "$INCLUDEPATH" ]; then
    rm -rf "$INCLUDEPATH"
fi

mkdir $INCLUDEPATH

copyIncludes
































